<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<html>
  <head>
    <meta charset="UTF-8">
    <title>忘记密码 - 4399Hotel</title>
    <link rel="icon" href="images/icon.jpg">
    <link href="stylesheets/forget.css" type="text/css" rel="stylesheet">
    <style>
        html,body{
            height: 100%;
            background-color:#f1f1f1 ;
            margin: 0;
            padding: 0;
        }
    </style>

  </head>
  
  <body>
    <div class="logoDiv">
    	<a href="login.jsp">
        	<img src="images/logo.png" class="logoImg">
    	</a>
	</div>
	<div class="login">
	    <a href="" class="aLogin">忘记密码</a>
	    <form action="/HotelSystem/Servlets/ForgetPwdServlet" class="inputForm" method="post">
	        <div>
	                <span>
	                     <img class="accImg" src="images/account.jpg">
	                </span>
	            <input type="text" placeholder="邮箱账号" class="accountInput" autocomplete="off" name="account" id="account">
	        </div>
	        <div>
	                <span>
	                     <img class="pwdImg" src="images/pwd.jpg">
	                </span>
	            <input type="password" placeholder="设置密码" class="pwdInput" autocomplete="off" name="pwd">
	        </div>
	         <div>
                <span>
                     <img class="pwdImg" src="images/pwd.jpg">
                </span>
            	<input type="password" placeholder="确认密码" class="pwdInput" autocomplete="off" name="surePwd">
        	</div>
        	<div>
                <span>
                     <img class="pwdImg" src="images/pwd.jpg">
                </span>
                <a style="position: absolute;line-height:40px;font-size:12px;margin-left: 230px;color: #3882E5;" onclick="return sendEamil()" id="sendText" href="javascript:;">发送验证码</a>
            	<input type="text" placeholder="邮箱验证码" class="pwdInput" autocomplete="off" name="code">
        	</div>
        	<input type="hidden" name="systemCode" id="systemCode">
	        <div style="font-size: 12px;color: #999; width: 80%;margin: 10px auto">
	            点击 “注册” 即表示您同意并愿意遵守简书
	            <a href="register.jsp" style="color: #3194d0;text-decoration: none"><span>用户协议</span></a>和<a href="register.jsp" style="color: #3194d0;text-decoration: none"><span>隐私政策</span></a>。
	        </div>
	        <input type="submit" value="修改" class="inputBtn">
	        <script type="text/javascript">
		  		function sendEamil(){
		  			var account = document.getElementById("account").value;
		  			var sendText = document.getElementById("sendText");
		  			var systemCodeEle = document.getElementById("systemCode");
		  			if(account == "" || account == null){
		  				alert("请先输入邮箱账号，再进行修改！");
		  				return true;
		  			}
		  			var xhr = new XMLHttpRequest();
		  			var url = "Servlets/SendEamilServlet?acc="+account;
		  			xhr.open("get",url,true);
		  			xhr.onreadystatechange = function(){
		  				if(xhr.readyState == 4){
		  					sendText.innerHTML = "已发送";
		  					systemCodeEle.value = xhr.responseText;
		  					return false;
		  				}
		  			}
		  			// 发送请求 
		  			xhr.send();
		  		}
  			</script>
	    </form>
	</div>
  </body>
</html>
